<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<img id="Light" src="../img/010.jpeg" width="200" height="120"><br>

<div class="cls">传智教育</div>
<div class="cls">黑马程序员</div>

<input type="checkbox" name="hobby">电影
<input type="checkbox" name="hobby">旅游
<input type="checkbox" name="hobby">游戏
<br>

<script>



    //1.getElementById：根据id的属性值来获取，返回一个数组对象
    let img = document.getElementById("Light");
    // document.write(img);
    img.src="../img/011.jpeg";

    //2.getElementsByTagName:根据标签名称获取，返回Element对象数组
    let divs = document.getElementsByTagName("div");
    /*
     style:设置元素css样式
     innerHTML：设置元素内容
   */

    for (let i = 0; i < divs.length; i++) {
        // divs[i].style.color="red";
        divs[i].innerHTML='hehe';
    }





    //3.getElementsByName:根据name属性值获取，返回Element对象数组
    let hobbys = document.getElementsByName("hobby");
    for (let i = 0; i < hobbys.length; i++) {
       hobbys[i].checked = true;
    }

    //4.getElementsByClassName:根据class属性值获取，返回Element对象数组
    let clss = document.getElementsByClassName("cls");
    /*    for (let i = 0; i < clss.length; i++) {
        alert(clss[i]);
      }
  */

</script>

</body>
</html>